﻿using ArxOne.MrAdvice.Advice;
using System;

namespace SlamDunk.MES.DataDrive.Bussiness
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Assembly)]
    public class StringNullValueToNullAttribute : Attribute, IPropertyAdvice
    {

        public void Advise(PropertyAdviceContext context)
        {
            if (context.HasValue)
            {
                if (context.Value != null && context.Value.ToString().ToLower() == "null")
                {
                    context.Value = null;
                }
            }
            context.Proceed();
        }
    }
}
